﻿#include <vector>
#include <iostream>

class Object {
    int num;

public:
    Object(int n) : num(n)
    {
        std::cout << "构造函数" << std::endl;
    }

    Object(const Object& p) : num(p.num)
    {
        std::cout << "拷贝构造函数" << std::endl;
    }

    Object(const Object&& p) noexcept : num(p.num)
    {
        std::cout << "移动构造函数" << std::endl;
    }
};

int main()
{
    std::vector<Object> objArray;

    std::cout << "创建测试对象:" << std::endl;
    auto obj = Object(1);
    std::cout << std::endl;

    auto obj2 = Object(1);
    std::cout << std::endl;

    std::cout << "1. xxxx_back(obj):" << std::endl;
    objArray.emplace_back(obj);
    std::cout << std::endl;

    objArray.push_back(obj2);
    std::cout << std::endl;

    std::cout << "2. xxxx_back(std::move(obj)):" << std::endl;
    objArray.emplace_back(std::move(obj));
    std::cout << std::endl;

    objArray.push_back(std::move(obj2));
    std::cout << std::endl;

    std::cout << "3. xxxx_back(1):" << std::endl;
    objArray.emplace_back(1);
    std::cout << std::endl;

    objArray.push_back(1);
    std::cout << std::endl;

    std::cout << "4. xxxx_back(Object(1)):" << std::endl;
    objArray.emplace_back(Object(1));
    std::cout << std::endl;

    objArray.push_back(Object(1));
    std::cout << std::endl;
}
